﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.SqlClient;
using DBUtility;
using System.Data;
using System.Text;
using TTSModel;
using TTSIDAL;
namespace TTSDAL
{
    public class AirtightnessTek : BaseRepository_DT<AirtightnessTekInfo>, IAirtightnessTek
    {
         #region 静态变量定义

        private const string PARM_KccSN = "@KccSN";
        private const string PARM_RecordTime = "@RecordTime";
        private const string PARM_ProductType = "@ProductType";
        private const string PARM_StartTime = "@StartTime";
        private const string PARM_EndTime = "@EndTime";
        private const string PARM_UserId= "@UserId";
        private const string PARM_TestValue = "@TestValue";
        private const string PARM_TestResult= "@TestResult";
        #endregion

        #region 数据检索部分
        public IList<AirtightnessTekInfo> LoadEntities()
        {
            return null;
        }
        public IList<AirtightnessTekInfo> AirtightnessTekInfo_GetbyKccSN(string KccSN)
        {
            SqlParameter parm = GetParameter();
            parm.Value = KccSN;
            return ExcuteSqlToGetEntities("AirtightnessTek_SelectByKccSN", parm);
        }
        public IList<AirtightnessTekInfo> AirtightnessTekInfo_GetbyDT(DateTime _startTime, DateTime _endTime)
        {
            SqlParameter[] parms = new SqlParameter[]
            { 
                new SqlParameter(PARM_StartTime, SqlDbType.DateTime),
                new SqlParameter(PARM_EndTime, SqlDbType.DateTime),
            };
            parms[0].Value = _startTime;
            parms[1].Value = _endTime;
            return ExcuteSqlToGetEntities("AirtightnessTek_SelectByDT", parms);
        }
        public AirtightnessTekInfo LoadEntity<T1>(T1 id)
        {          
            return null;
        }

       
        #endregion

        #region 重写基类方法
         public override string GetInsertsp()
        {
            return "AirtightnessTek_Insert";
        }
        public override AirtightnessTekInfo GetEntityRecord(SqlDataReader rdr)
        {
            AirtightnessTekInfo entity = new AirtightnessTekInfo()
            {
               KccSN = rdr.GetString(0),
               RecordTime = rdr.GetDateTime(1),
               ProductType=rdr.GetString(2),
               UserId=rdr.GetString(3),
               TestValue=rdr.GetInt32(4),
               TestResult=rdr.GetString(5)
            };
            return entity;
        }

        public override AirtightnessTekInfo GetEntityRecord()
        {
            AirtightnessTekInfo entity = new AirtightnessTekInfo();
            return entity;
        }

        public override SqlParameter GetParameter()
        {
            SqlParameter parm = new SqlParameter(PARM_KccSN, SqlDbType.NVarChar, 50);
            return parm;
        }

        public override SqlParameter[] GetParameters()
        {
            SqlParameter[] parms = new SqlParameter[]
            {              
                new SqlParameter(PARM_KccSN,SqlDbType.NVarChar,50),
                new SqlParameter(PARM_RecordTime,SqlDbType.DateTime),
                new SqlParameter(PARM_ProductType,SqlDbType.NVarChar,10),
                new SqlParameter(PARM_UserId,SqlDbType.NVarChar,10),
                new SqlParameter(PARM_TestValue,SqlDbType.Int),
                new SqlParameter(PARM_TestResult,SqlDbType.NVarChar,10),
            };
            return parms;
        }

        public override void SetParameters(AirtightnessTekInfo Entity, params SqlParameter[] Parms)
        {
            Parms[0].Value = Entity.KccSN;
            Parms[1].Value = Entity.RecordTime;
            Parms[2].Value = Entity.ProductType;
            Parms[3].Value = Entity.UserId;
            Parms[4].Value = Entity.TestValue;
            Parms[5].Value = Entity.TestResult;
        }
        #endregion
   
    }
}
